import { useEffect, useState } from 'react';
import NavBar from '../../components/NavBer'
import { getDeivce } from '../../request'

import './select.css'

function Select() {
    const [list, setList] = useState([])

    const getDate = async () => {
        const { data, code } = await getDeivce()
        console.log(data);
        if (code == 200) {
            setList(data)
        }
    }

    useEffect(() => {
        getDate()
    }, [])


    return (
        <div style={{backgroundColor: '#eee'}}>
            <NavBar title="选择设备" />

            <div className="box">
                {list.map(item =>
                    <div className='one' key={item._id}>
                        <img src={item.img} />
                        <p>{item.name}</p>
                    </div>
                )}
            </div>

        </div>
    );
}

export default Select;